package com.qing.eduservice.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qing.eduservice.entity.pojo.EduCourse;
import com.qing.eduservice.entity.pojo.EduTeacher;
import com.qing.eduservice.entity.vo.CourseQueryVo;
import com.qing.eduservice.service.EduCourseService;
import com.qing.eduservice.service.EduTeacherService;
import com.qing.servicebase.utils.ResponseResult;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName Yjx
 * @Description TODO
 * @date 2022/9/17 11:53
 * @Version 1.0
 */
@RestController
@RequestMapping("/eduservice/front/course")
@CrossOrigin
public class FrontCourseController {

    private final EduCourseService eduCourseService;

    private final EduTeacherService eduTeacherService;

    public FrontCourseController(EduCourseService eduCourseService, EduTeacherService eduTeacherService) {
        this.eduCourseService = eduCourseService;
        this.eduTeacherService = eduTeacherService;
    }

    @GetMapping(value = "/{id}")
    public ResponseResult getById(@PathVariable String id){
        return eduCourseService.selectByTeacherId(id);
    }

    @PostMapping(value = "/page/{page}/{pageSize}")
    public ResponseResult pageList(@PathVariable("page") int page, @PathVariable("pageSize") int pageSize,
                      @RequestBody CourseQueryVo courseQuery){
        Page<EduCourse> pageParam = new Page<EduCourse>(page, pageSize);
        return eduCourseService.pageListWeb(pageParam,courseQuery);
    }

}
